﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="find_by_level.aspx.cs" Inherits="SQT.tracnghiem.Ajax.ASP.User.find_by_level" %>

<%@ Import Namespace="DataAccess" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<body>
    <%
        string id = Request.QueryString["id"];
        
         %>
    <tr class="w3-teal">
        <th>Ảnh</th>
        <th>Mã HV</th>
        <th>Tên đăng nhập</th>
        <th>Quyền</th>
        <th>Họ tên</th>
        <th>Ngày sinh</th>
        <th>Giới tính</th>
        <th>SĐT</th>
        <th>Email</th>
        <th>Kích hoạt</th>
        <th>Xóa</th>
        <th>Sửa</th>
    </tr>
    <%
        var get_user = (from p in new TblUserController().FetchAll() orderby p.UserId descending where p.UserLevel == int.Parse(id) && p.UserId!=0 select p);
        if (id == "")
            get_user = (from p in new TblUserController().FetchAll() orderby p.UserId descending select p);
        var get_level = new TblUserRoleController().FetchAll();
        foreach (TblUser user in get_user)
        {
    %>
    <tr id="user<%=user.UserId %>" class="user">
        <td class="w3-hide user_id"><%=user.UserId %></td>
        <td class="staff-img">
            <img src="../Content/avatar/<%=user.Avatar %>" class="w3-circle" /></td>
        <td><%=user.NumberStudy %></td>
        <td><%=user.UserName %></td>
        <td>
            <select style="padding: 1.1%" class="change_level">
                <%
                        foreach (TblUserRole role in get_level)
                        { %>
                <%if (user.UserLevel == role.RoleId)
                  {%>
                <option value="<%=role.RoleId %>" selected="selected"><%=role.RoleName %></option>
                <%}
                  else
                  { %>
                <option value="<%=role.RoleId %>"><%=role.RoleName %></option>
                <%}
                        } %>
            </select>
        </td>
        <td><%=user.FullName %></td>
        <td><%=DateTime.Parse(user.BirthDay.ToString()).Day+"/"+DateTime.Parse(user.BirthDay.ToString()).Month+"/"+DateTime.Parse(user.BirthDay.ToString()).Year %></td>
        <td><%if (user.Sex == true)
              { %>Nam<%}
              else
              { %>Nữ<%} %></td>
        <td><%=user.Phone %></td>
        <td><%=user.Email %></td>
        <%if (user.Active == true)
          {%>
        <td class="option-btn">
            <i class="on2 fa fa-toggle-on w3-text-teal w3-animate-opacity"></i>
        </td>
        <%}
          else
          { %>
        <td class="option-btn">
            <i class="on2 fa fa-toggle-on w3-text-red w3-animate-opacity fa-rotate-180 off "></i>
        </td>
        <%} %>
        <td class="option-btn"><i onclick="document.getElementById('xoanhanvien').style.display = 'block'" class="user_del fa fa-trash"></i></td>
        <td class="option-btn"><i class="fa fa-wrench user_edit"></i></td>
    </tr>
    <%} %>
</body>
</html>
